home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
c
/
snz128s
/
src
/
rebuild.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-04-05
|
2KB
|
138 lines
head 1.1;
access;
symbols;
locks
user:1.1;
comment @// @;
1.1
date 94.04.05.18.38.36; author gbj; state Exp;
branches;
next ;
desc
@Version 1.28
@
1.1
log
@Initial revision
@
text
@//=========================================================
//
// rebuild
//
// Simple envelope for reindex.
//
// It reads the active file ~\spool\news\nntp.dat and runs
// reindex for each group it finds.
//
//=========================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(void)
{
char *buf;
char *cmd;
char *file;
char *path;
char *f1;
int junk;
FILE *nntp;
buf=(char*)malloc(81);
cmd=(char*)malloc(81);
file=(char*)malloc(129);
if (!buf || !cmd || !file)
{
fprintf(stderr,"rebuild: Can't allocate memory\n");
if (buf)
free(buf);
if (cmd)
free(cmd);
if (file)
free(file);
exit(1);
}
path=getenv("NOS_ROOT");
if (!path)
{
fprintf(stderr, "rebuild: NOS_ROOT environment variable not defined\n");
free(buf);
free(cmd);
free(file);
exit(2);
}
junk=strlen(path)-1;
if (path[junk] == '\\' || path[junk] == '/')
path[junk]='\0';
strcpy(file, path);
strcat(file,"\\spool\\news\\nntp.dat");
fprintf(stderr,"Filepath is %s\n", file);
nntp=fopen(file, "r");
if (!nntp)
{
fprintf(stderr, "rebuild: Cannot open %s\n", file);
free(buf);
free(cmd);
free(file);
exit(3);
}
// Process the records in nntp.dat
// The format must be...
// NewsServer line
// blank line
// Groups, one per line, indented by whitespace
//
// NOTE: this program DOES NOT cope with multiple news servers.
if (!fgets(buf, 80, nntp))
{
fprintf(stderr, "rebuild: news server line not found\n");
fclose(nntp);
free(buf);
free(cmd);
free(file);
exit(4);
}
if (!fgets(buf, 80, nntp))
{
fprintf(stderr, "rebuild: blank flag line not found\n");
fclose(nntp);
free(buf);
free(cmd);
free(file);
exit(4);
}
while (fgets(buf, 80, nntp))
{
f1=strtok(buf, " \t\r\n");
if (f1) {
sprintf(cmd, "reindex %s\n", f1);
junk=system(cmd);
}
}
fclose(nntp);
free(buf);
free(cmd);
free(file);
exit(0);
}@